package de.mhu.demo;

import de.mhu.mandalaui.Ui;
import de.mhu.mandalaui.Window;
import de.mhu.mandalaui.actions.AlertInfoAction;
import de.mhu.mandalaui.actions.ClickAction;
import de.mhu.mandalaui.layout.HorizontalLayout;
import de.mhu.mandalaui.layout.Panel;
import de.mhu.mandalaui.properties.PropertiesTable;
import de.mhu.mandalaui.properties.StringProperty;
import de.mhu.mandalaui.table.StaticTable;
import de.mhu.mandalaui.table.TableHeader;
import de.mhu.mandalaui.table.TableRow;
import de.mhu.mandalaui.text.Text;

public class DemoStaticTable {

	public Window createWindow(String id) {
		Window window = Ui.createWindow(id);
		
		HorizontalLayout layout = new HorizontalLayout();
		window.setContent(layout);
		
		Panel left = new Panel("Left");
		layout.add(left, new HorizontalLayout.Options(3));
		
		StaticTable table = new StaticTable();
		table.setHeader(new TableHeader( new Text("Name") ));

		ClickAction action = new AlertInfoAction();
		table.setSelectAction(action);
//		table.setActiveAction();
		table.getRows().add(new TableRow(new Text("Klaus")));
		table.getRows().add(new TableRow(new Text("Foo")));
		table.getRows().add(new TableRow(new Text("Adam")));
		table.getRows().add(new TableRow(new Text("Eva")));
		
		left.add(table);
		
		Panel right = new Panel("Right");
		layout.add(right, new HorizontalLayout.Options(9));

		PropertiesTable properties = new PropertiesTable();
		
		right.add(properties);
		
		properties.add(new StringProperty(null,"Value"), new PropertiesTable.Options("String"));

		properties.add(new StringProperty(null,"FooBar"), new PropertiesTable.Options("String2"));

		
		return window;
	}
}
